package com.tscnd.core.service.role.impl;

import java.util.List;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.tscnd.core.dao.role.IRoleDao;
import com.tscnd.core.entity.role.Role;
import com.tscnd.core.exception.TSException;
import com.tscnd.core.service.role.IRoleService;

@Service("roleService")
public class RoleServiceImpl implements IRoleService {
	@Autowired
	private IRoleDao roleDao;

	@Override
	public List<Role> getAll() throws TSException
	{
		try
		{
			return roleDao.getAll();
		} catch (Exception e)
		{
			e.printStackTrace();
			throw new TSException("查询所有角色信息失败\r\n" + e.getMessage());
		}
	}

	@Override
	public Set<Role> findUserByRole(String username) throws TSException
	{
		try
		{
			return roleDao.findUserByRole(username);
		} catch (Exception e)
		{
			e.printStackTrace();
			throw new TSException("根据用户名查询角色信息失败\r\n" + e.getMessage());
		}
	}
}
